package com.jzcn.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jzcn.common.base.BaseServiceImpl;
import com.jzcn.common.dto.log.LogListDTO;
import com.jzcn.common.dto.log.LoginLogDTO;
import com.jzcn.common.dto.log.SearchLogDTO;
import com.jzcn.common.dto.log.SearchLoginLogDTO;
import com.jzcn.common.utils.BeanUtils;
import com.jzcn.common.utils.JzPage;
import com.jzcn.domain.SysLog;
import com.jzcn.domain.SysLoginLog;
import com.jzcn.mapper.SysLogMapper;
import com.jzcn.mapper.SysLoginLogMapper;
import com.jzcn.service.SysLogService;
import com.jzcn.service.SysLoginLogService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class SysLoginLogServiceImpl extends BaseServiceImpl<SysLoginLogMapper, SysLoginLog> implements SysLoginLogService {

    @Override
    public JzPage<LoginLogDTO> listPage(SearchLoginLogDTO query) {
        IPage<SysLoginLog> iPage = new Page<>(query.getPageNum(), query.getPageSize());
        return BeanUtils.convertPage(new JzPage<>(baseMapper.findPage(iPage,query)),LoginLogDTO.class);
    }

    @Override
    public Boolean saveLoginLog(LoginLogDTO bo) {
        SysLoginLog sysLoginLog = BeanUtils.convert(bo,SysLoginLog.class);
        return super.save(sysLoginLog);
    }
}
